package com.sushi.config;


import com.alibaba.druid.pool.DruidDataSource;
import com.sushi.dao.StudentDao;
import com.sushi.dao.UserDao;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import javax.sql.DataSource;

//@Configuration
@PropertySource("classpath:jdbc.properties")
public class DaoConfig {

    @Value("${jdbc.password}")
    private String password;
    @Value("${jdbc.driver}")
    private String driver;
    @Value("${jdbc.url}")
    private String url;
    @Value("${jdbc.username")
    private String name;

    @Bean("dataSource")
    public DataSource getDataSource(StudentDao studentDao) {
        System.out.println(studentDao);
        DruidDataSource ds = new DruidDataSource();
        ds.setPassword(password);
        ds.setUrl(url);
        ds.setName(name);
        ds.setDriverClassName(driver);
        return ds;
    }

}
